package ${appProperty.basePackage}.controller;

import com.autonavi.abs.common.aop.annotation.FullLog;
import com.autonavi.abs.common.base.PageResult;
import ${appProperty.basePackage}.service.${tableMeta.upperName}Service;
import ${appProperty.basePackage}.model.dto.${tableMeta.upperName}DTO;
import ${appProperty.basePackage}.model.query.${tableMeta.upperName}Query;
import com.autonavi.abs.common.api.ServiceResponse;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
* @author ${appProperty.author}
* @version V1.0
* <p>Description: ${tableMeta.upperName} Controller</p>
* @date ${appProperty.dateTime}
*/
@RestController
@RequestMapping(value = "/api/v1/${tableMeta.camelName}")
public class ${tableMeta.upperName}Controller {

    @Resource(name = "${tableMeta.camelName}Service")
    private ${tableMeta.upperName}Service ${tableMeta.camelName}Service;

    @RequestMapping("/add")
    @FullLog
    public ServiceResponse add(@RequestBody ${tableMeta.upperName}DTO dto) throws Exception {
        return ServiceResponse.success(${tableMeta.camelName}Service.insert(dto));
    }

    @RequestMapping("/update")
    @FullLog
    public ServiceResponse update(@RequestBody ${tableMeta.upperName}DTO dto) throws Exception {
        return ServiceResponse.success(${tableMeta.camelName}Service.updateById(dto));
    }

    @RequestMapping("/delete")
    @FullLog
    public ServiceResponse delete(Long id) throws Exception {
        return ServiceResponse.success(${tableMeta.camelName}Service.deleteById(id));
    }

    @RequestMapping("/page")
    @FullLog
    public PageResult<${tableMeta.upperName}DTO> page(@RequestBody ${tableMeta.upperName}Query query) {
        return ${tableMeta.camelName}Service.selectPageByQuery(query);
    }

}
